package logic

import (
	"context"
	"video-manager/usersrpc/usersrpc"

	"video-manager/api/internal/svc"
	"video-manager/api/internal/types"

	"github.com/zeromicro/go-zero/core/logx"
)

type UpUserMessageLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewUpUserMessageLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UpUserMessageLogic {
	return &UpUserMessageLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *UpUserMessageLogic) UpUserMessage(req *types.UpUserMessageRequest) (resp *types.Response, err error) {
	// todo: add your logic here and delete this line
	data, err := l.svcCtx.UsersRpc.UpUserMessage(l.ctx, &usersrpc.UpUserMessageRequest{
		NickName: req.Nick_name,
		UserId:   int64(req.UserId),
	})
	if err != nil {
		return &types.Response{
			Message: err.Error(),
			Data:    nil,
			Code:    500,
		}, nil
	}

	return &types.Response{
		Message: "修改成功",
		Data:    data,
		Code:    200,
	}, nil

}
